#include "preCmpH.h"
#include "UIException.h"

UIException::UIException()
	: code_(0)
	, msg_("")
	, file_("")
	, class_("")
	, function_("")
	, text_("")
{}
UIException::UIException(int code)
	: code_(code)
	, msg_("")
	, file_("")
	, class_("")
	, function_("")
	, text_("")
{}
UIException::UIException(const char* msg)
	: code_(0)
	, msg_(msg)
	, file_("")
	, class_("")
	, function_("")
	, text_("")
{}
UIException::UIException(const char* msg, int code)
	: code_(code)
	, msg_(msg)
	, file_("")
	, class_("")
	, function_("")
	, text_("")
{}
UIException::UIException(const char* msg, const char* in_file, const char* in_class, const char* in_method)
	: code_(0)
	, msg_(msg)
	, file_(in_file)
	, class_(in_class)
	, function_(in_method)
	, text_("")
{}
UIException::UIException(const char* msg, const char* in_file, const char* in_class, const char* in_method, int code)
	: code_(code)
	, msg_(msg)
	, file_(in_file)
	, class_(in_class)
	, function_(in_method)
	, text_("")
{}
UIException::UIException(const UIException& e)
{
	code_ = e.code_;
	msg_ = e.msg_;
	file_ = e.file_;
	class_ = e.class_;
	function_ = e.function_;
	text_ = e.text_;
}
const char* UIException::what()
{
	text_ = "==============================\n";
	text_ += "Error Code : Unknown \n";
	if( code_ != 0){
	text_ = "Error Code : " + std::to_string(code_) + "\n";
	}
	if(!msg_.empty()){
	text_ = text_ + "Message : " + msg_ + "\n";
	}
	if(!file_.empty()){
	text_ = text_ + "Thrown from file : " + file_ + "\n";
	}
	if(!class_.empty()){
	text_ = text_ + "Inside class : " + class_ + "\n";
	}
	if(!function_.empty()){
	text_ = text_ + "Inside function : " + function_ + "\n";
	}
	text_ += "==============================\n";
	return text_.c_str();
}

void UIException::setFile( const char* in_file )
{
	file_ = in_file;
}

void UIException::setClass( const char* in_class )
{
	class_ = in_class;
}

void UIException::setFunction( const char* in_function )
{
	function_ = in_function;
}
